package com.sinosoft.brokerchannel.rest;

import com.sinosoft.brokerchannel.base.annotation.MyResponseBody;
import com.sinosoft.brokerchannel.base.common.SystemParamFinal;
import com.sinosoft.brokerchannel.base.rest.AbstractController;
import com.sinosoft.brokerchannel.base.server.LogService;
import com.sinosoft.brokerchannel.base.utile.BusinessException;
import com.sinosoft.brokerchannel.entity.vo.ImageCloudStorageRequest;
import com.sinosoft.brokerchannel.entity.vo.ImageCloudStorageResponse;
import com.sinosoft.brokerchannel.server.CarQuotePriceService;
import com.sinosoft.brokerchannel.server.ImageCloudStorageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * 需求名称：[保险经纪渠道平台]<br/>
 *
 * @author gzj
 * @version V1.0
 * @date 2018-8-21 10:48
 * 影像云存储
 */
@Api(value = "services", description = "车险渠道平台影像云存储")
@Controller
@RequestMapping("/image")
public class ImageCloudStorageController extends AbstractController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private ImageCloudStorageService imageCloudStorageService;
    @Autowired
    private LogService logService;

    @RequestMapping(value = "/imagecloudstorage", method = RequestMethod.POST, produces = {"application/xml;charset=UTF-8", "application/json;charset=UTF-8"}, consumes = {"application/xml;charset=UTF-8", "application/json;charset=UTF-8"})
    @ApiOperation(value = "影像云存储", notes = "影像云存储", position = 6)
    @ApiResponses({@ApiResponse(code = 400, message = "失败")})
    @MyResponseBody
    public ImageCloudStorageResponse imagecloudstorage(@RequestBody ImageCloudStorageRequest request) throws Exception {
        //响应对象
        ImageCloudStorageResponse response = null;
        try {
            //初始化
            super.init("影像云存储", request.getRequestHead());
            //调用服务
            response = imageCloudStorageService.imageCloudStorage(request);
            super.sucessAction();
        } catch (BusinessException e) {
            logger.info(SystemParamFinal.Exception_LOG, e);
            super.businessExceptionAction(e);
        } catch (Exception e) {
            super.exceptionAction(e);
            logger.info(SystemParamFinal.Exception_LOG, e);
        } finally {
            if (response == null) {
                response = new ImageCloudStorageResponse();
            }
            response.setResponseHead(super.getResponseHead());
        }
        return response;
    }
}
